#ifndef RECORD_DESKTOP
#define RECORD_DESKTOP


#include"../util/Rect.h"
#include <atomic>
#include <thread>
#include <functional>
#include "video.h"
#include "signal.hpp"


class record_desktop
{
public:
	record_desktop();
	virtual ~record_desktop();

	virtual int init(
		const Rect& rect,
		const int fps
	) = 0;

	virtual int start() = 0;
	virtual int pause() = 0;
	virtual int resume() = 0;
	virtual int stop() = 0;

public:
	inline bool is_recording() { return _running; }
	inline const std::string& get_device_name() { return _device_name; }
	inline const int get_frame_rate() { return _fps; }


	sigslot::signal<FRAME_PKG*> _on_data;

protected:
	virtual void clean_up() = 0;
	void do_sleep(int64_t dur, int64_t pre, int64_t now);

protected:

	std::atomic_bool _running;
	std::atomic_bool _paused;
	std::atomic_bool _inited;

	std::thread _thread;

	std::string _device_name;

	Rect _rect;

	FRAME_PKG* _imgBuf;

	int _fps;

};


#endif